package calendar_test;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CalendarTest {

	public static void main(String[] args) {
		calendarWorks();
		splitMiddle();
		testTimestamp();

	}

	public static void testTimestamp() {
		String str = "2015-02-25 11:11:11";
		Timestamp t = Timestamp.valueOf(str);
		System.out.println("time : " + str);
		System.out.println("t.getTime " + t.getTime());
		System.out.println("t.toString " + t.toString());
	}

	private static void splitMiddle() {
		String line = "101270339[_cvs_c_dgn_]43531";
		if (line.contains("[_cvs_c_dgn_]")) {
			String[] info = line.split("\\[_cvs_c_dgn_\\]");// 101270339_43531
			System.out.println("imageId : " + info[0] + " providerId " + info[1]);
		}
		
	}

	private static void calendarWorks() {
		int tzOff = -3;
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.MONTH, tzOff);
		System.out.println(df.format(calendar.getTime()));
	}

}
